package com.clothing.customization.repository;

import com.clothing.customization.entity.Appointment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface AppointmentRepository extends JpaRepository<Appointment, Long> {
    
    // 根据状态统计预约数量
    long countByStatus(Integer status);
    
    // 根据创建时间范围统计预约数量
    long countByCreateTimeBetween(Date startTime, Date endTime);
    
    // 获取最近4条待处理预约
    List<Appointment> findTop4ByStatusOrderByAppointmentTimeAsc(Integer status);
    
    // 根据用户ID查询预约列表
    List<Appointment> findByUserIdOrderByAppointmentTimeDesc(Long userId);
    
    // 根据设计师ID查询预约列表
    List<Appointment> findByDesignerIdOrderByAppointmentTimeDesc(Long designerId);
    
    // 根据预约号查询预约
    Appointment findByAppointmentNo(String appointmentNo);
    
    // 根据状态查询预约列表
    List<Appointment> findByStatusOrderByAppointmentTimeAsc(Integer status);
    
    // 根据用户ID和状态查询预约列表
    List<Appointment> findByUserIdAndStatusOrderByAppointmentTimeAsc(Long userId, Integer status);
    
    // 根据设计师ID和状态查询预约列表
    List<Appointment> findByDesignerIdAndStatusOrderByAppointmentTimeAsc(Long designerId, Integer status);
    
    // 统计用户预约数量
    long countByUserId(Long userId);
    
    // 统计设计师预约数量
    long countByDesignerId(Long designerId);
    
    // 根据预约时间范围查询预约列表
    List<Appointment> findByAppointmentTimeBetweenOrderByAppointmentTimeAsc(Date startTime, Date endTime);
    
    // 根据设计师ID和预约时间范围查询预约列表
    List<Appointment> findByDesignerIdAndAppointmentTimeBetweenOrderByAppointmentTimeAsc(Long designerId, Date startTime, Date endTime);
} 